package bman.filecopy;

import java.io.File;
import java.io.FilenameFilter;

public class Filter implements FilenameFilter
{
	String pattern;
	
	public Filter(String pattern)
	{
		this.pattern = pattern;
		this.pattern = pattern.replaceAll("\\*",".*");
	}
	
	public boolean accept(File dir, String name)
	{
		File f = new File(dir.getAbsolutePath()+File.separatorChar+name);
		/*
		 *  don't copy directories.
		 */
		return !f.isDirectory() && name.matches(pattern);
	}

}
